package com.alibaba.springboot.health.controller;

import com.alibaba.springboot.health.pojo.Cart;
import com.alibaba.springboot.health.service.CartService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.github.pagehelper.PageInfo;

/**
 * (Cart)表控制层
 *
 * @author makejava
 * @since 2019-12-24 14:33:36
 */
@Controller
@RequestMapping("cart")
public class CartController {
    /**
     * 服务对象
     */
    @Autowired
    private CartService cartService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping("searchOne")
    @ResponseBody
    public Cart searchOne(Integer id) {
        return cartService.queryById(id);
    }
    
    
    /**
     * 查询多条数据
     * @param page 页码
     * @param pageSize 页大小
     * @param cart 实体
     * @return PageInfo<Cart> 分页数据集合
     */
    @RequestMapping("searchAll")
    @ResponseBody
    public PageInfo<Cart> searchAll(@RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "pageSize",defaultValue = "5")int pageSize, Cart cart){
        return cartService.queryAll(page, pageSize, cart);
    }

}